/*
12. We are given integer number n, value v (v=0 or 1) and a position p. Write a sequence of operators that modifies n to hold the value v at the position p from the binary representation of n.
*/
using System;

class modifieBitAtPosition
{
    static void Main()
    {
        Console.Write("Enter an integer: ");
        int modifiedNumber = int.Parse(Console.ReadLine());

        Console.Write("Enter the position: ");
        int position = int.Parse(Console.ReadLine());
        
        Console.Write("Enter the value 0 or 1: ");
        int value = int.Parse(Console.ReadLine());

        int mask,result;
        if (value == 1)
        {
            mask = 1 << position;
            result = modifiedNumber | mask;
        }
        else
        {
            mask = ~(1 << position);
            result = modifiedNumber & mask;
        }
        Console.WriteLine("The modified number is {0}", result);
    }
}